package redis_springboot.demo.mq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import redis_springboot.demo.mq.MQConst;

import java.time.LocalDateTime;

/**
 * @author： pang-yun
 * @date： 2021-12-23 15:16
 * 功能目的 ：用于 死信队列 消费者
 */
@Slf4j
@Component
public class DeadLetterQueueConsumer {
    // 接收消息
    @RabbitListener(queues = MQConst.QUEUE_DEAD)
    public void receive(Message message) {
        String msg = new String(message.getBody());
        log.info("当前时间: {}, 收到死信队列的消息: {}", LocalDateTime.now().toString(),msg);
    }
}
